package com.yix.jpademo.entity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

@Entity
@Data
@Table(name="sys_user")
public class User {

    @Id
    @Column(
            name = "id",
            length = 32,
            nullable = false,
            columnDefinition = "varchar(32) COMMENT '主键id'"
    )
    @GenericGenerator(
            name = "uuid2",
            strategy = "org.hibernate.id.UUIDHexGenerator"
    )
    @GeneratedValue(
            generator = "uuid2"
    )
    protected String id;

    @Column(columnDefinition = "varchar(20) COMMENT '姓名'")
    private String name;

    @Column(columnDefinition = "int(3) COMMENT '年龄'")
    private Integer age;

    @Column(columnDefinition = "varchar(255) COMMENT '地址'")
    private String address;

    @ManyToOne
    @JoinColumn(columnDefinition = "varchar(32) COMMENT '关联部门'")
    @NotFound(action = NotFoundAction.IGNORE)
    private Dept dept;


}
